const Base = require('./base.js');

module.exports = class extends Base {
	/**
	 * @author: ares
	 * @date: 2018/5/28 15:18
	 * @description: 获取设备列表
	 * @returns {Promise.<void>}
	 */
	async getMyDeviceListAction() {
			let currentOpenId = this.ctx.state.openid,
			patientId = await this.model('patient').selectPatientByOpenId(currentOpenId).id,
			result = await this.model('device').getDeviceList();
			// result = await this.model('device').getMyDeviceList(patientId);
		this.success(result)
	}

	async getHistoryPageListAction() {
		let deviceId = this.get('deviceId'),
			currentPage = this.get('currentPage'),
			pageSize = this.get('pageSize'),
			deviceTypeId = await this.model('device').getDeviceTypeId(deviceId),
			result = await this.model('device').getHistoryList(deviceTypeId,deviceId, currentPage, pageSize);
		this.success(result)
	}

	async getReportDetailAction() {
		let deviceId = this.get('deviceId'),
			reportId = this.get('reportId'),
            deviceTypeId = await this.model('device').getDeviceTypeId(deviceId),
            result = await this.model('device').getReportDetail(deviceTypeId,reportId);
		this.success(result)
	}
};
